package WaiBao;

import java.util.Arrays;

public class LiMing {
    public static void main(String[] args) {
        String[] name = {"王继堂(班长)", "张金飘(宣传委员)", "小李(学习委员)", "李碑文(团支书)", "李胜义", "梁也成", "王镖旗", "刘汉申", "李匹配", "关麦杨", "宁红月", "候菜菜",
                "王浩申", "廖哥", "宜阳", "成型", "吴焕倩", "韩寒", "张翼德", "倪大红", "丁丁", "常汉卿", "候清", "刘琼", "魏大毛", "诸葛亮", "诸葛瑾", "刘备",
                "敖丙", "李敏(心理委员)"};//考生本人:李敏(心理委员)
        int[] age = {19,20, 20, 18, 20,21, 23, 18, 19, 19, 18, 19, 18, 22, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 19};//最后一位考生本人年龄：19

        double[] sepal1 = {84, 88,58,87, 79, 68, 78, 99, 60, 80, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 84, 89, 96};
        double[] sepal2 = {64, 91, 77, 84, 68, 87, 78, 83, 60, 90, 90, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 79, 84, 95};
        double[] sepal3 = {77, 89, 65, 64, 81, 75, 62, 69, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 95};


        double pine;//代表每个学生的总分
        double stalk;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            pine = sepal1[i] + sepal2[i] +sepal3[i];
//            stalk = (pine * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + pine);
//            System.out.println(name[i] + "的平均分为:" + stalk);
//        }

        double pollen = 0, cone = 0;
        double[] bamboo = new double[30];
//        for (int i = 0; i < 30; i++) {
//            pollen = sepal1[i] +sepal2[i] + sepal3[i];
//            cone= ( pollen * 1.0) / 3;
//            bamboo[i] = cone;
//        }
//
//        for (int i = 0; i < bamboo.length - 1; i++) {
//            for (int j = 0; j < bamboo.length - i - 1; j++) {
//                if ( bamboo[j] <  bamboo[j + 1]) {
//                    double temp =  bamboo[j];
//                    bamboo[j] = bamboo[j + 1];
//                    bamboo[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( bamboo[i]);
//        }



        double box1 = 0, box2 = 0, box3 = 0;//计算每门课的平均分
        double poplar1 = 0,poplar2 = 0,poplar3 = 0;//计算每门课标准差
        double fir1 = 0,  fir2 = 0,  fir3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < sepal1.length; i++) {
            sum2+=sepal1[i];
        }
        box1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+ box1);
        double Sum = 0;
        for (int i = 0; i < sepal2.length; i++) {
            Sum+=sepal2[i];
        }
        box2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+ box2);
        double sum = 0;
        for (int i = 0; i <sepal3.length; i++) {
            sum+=sepal3[i];
        }
        box3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+ box3);


        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < sepal1.length; i++) {
            c1+= (sepal1[i] - box1)*(sepal1[i] -  box1);
        }
        poplar1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ poplar1);

        for (int i = 0; i <sepal2.length; i++) {
            c2+= (sepal2[i] - box2)*(sepal2[i] - box2);
        }
        poplar2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ poplar2);

        for (int i = 0; i <sepal3.length; i++) {
            c3+= (sepal3[i] -  box3)*(sepal3[i] - box3);
        }
        poplar3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+poplar3);
////
//        Arrays.sort(sepal1);
//        Arrays.sort(sepal2);
//        Arrays.sort(sepal3);
//        fir1 =( sepal1[14]+sepal1[15])*1.0/2;
//        fir2 =( sepal2[14]+sepal2[15])*1.0/2;
//        fir3 =( sepal3[14]+sepal3[15])*1.0/2;
//        System.out.println("分析化学的中位数为:"+ fir1);
//        System.out.println("线性代数的中位数为:"+ fir2);
//        System.out.println("有机化学学的中位数为:"+ fir3);
    }
}
